﻿using NUnit.Framework;
using RenewalProjects.Libraries.Common.Testing.Interfaces;
using RenewalProjects.Libraries.Wcf.EasyProxy.ChannelAllocators;
using RenewalProjects.Libraries.Wcf.EasyProxy.ChannelHolders;
using RenewalProjects.Libraries.Wcf.EasyProxy.Tests.TestData;
using RenewalProjects.Libraries.Wcf.EasyProxy.Tests.TestBuilders;
using Rhino.Mocks;

namespace RenewalProjects.Libraries.Wcf.EasyProxy.Tests.Fixtures
{
	[TestFixture]
	public class TransientChannelAllocatorFixture : IUsesRhinoMocks
	{
	    #region Properties
	    
	    public MockRepository Mock { get; set; }
	    
	    #endregion
	    
		#region Test Methods

		[Test]
		public void TransientChannelAllocator_get_available_channel()
		{
			var channelFactoryHelper = new ChannelFactoryBuilder<ITest>(Mock).ExpectCreateChannel(new TestChannel());

			Mock.ReplayAll();

			ChannelHolderBase<ITest> channelHolder =
			        new TransientChannelAllocator<ITest>(
			                channelFactoryHelper.GetFactory(), channelFactoryHelper.GetServiceEndpoint())
			            .GetAvailableChannel();

			Assert.IsNotNull(channelHolder);
			Assert.IsInstanceOf<TransientChannelHolder<ITest>>(channelHolder);
		}

		#endregion
	}
}